package com.sm.dao;

import com.sm.entity.WagesLevel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WagesLevelDao {

    //查询工资等级
    @Select("select * from wages_level")
    public List<WagesLevel> findWagesLevel()throws Exception;

    //查询级别工资
    @Select("select amount from wages_level where id = #{id}")
    public Double findAmountByLevel(Double id)throws Exception;

    //添加工资级别
    @Insert("insert into wages_level(level,amount,description) values(#{level},#{amount},#{description})")
    public void addWagesLevel(WagesLevel wagesLevel)throws Exception;

    //更新工资级别
    @Update("<script> update wages_level " +
            "<set> " +
            " <if test='level != null'>level = #{level,jdbcType=VARCHAR},</if> " +
            " <if test='amount != null'>amount = #{amount,jdbcType=INTEGER},</if> " +
            " <if test='description != null'>description = #{description,jdbcType=VARCHAR},</if> " +
            " </set> " +
            " where id = #{id,jdbcType=INTEGER} </script>")
    public void UpdateWagesLevel(WagesLevel wagesLevel)throws Exception;

//    @Update("")
//    public void deleteWagesLevel(Integer id)throws Exception;
}
